<?php
  $nbrubrique=mysql_num_rows(mysql_query("SELECT id FROM rubrique WHERE titre LIKE '$page'"));
  if ($page == 'Zoom')
  	$page = 'page_id8';
  if ($page == 'news')
  	$page = 'page_id11';
?>
<?php
  $menuQuery = mysql_query("SELECT * FROM rubrique WHERE niveau=0 ORDER BY ordre");
  $menuCount = mysql_num_rows($menuQuery);
  $indexMenu = 1;
?>

<div class="navbar navbar-inverse">
  <div class="navbar-inner">
    <div class="container">
      <button type="button" class="btn btn-navbar"
      		id="buttonNavBar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <div class="nav-collapse collapse">
        <ul class="nav">
          <li class="menuHome <?php echo ($page == "homeContent") ? "active" : ""; ?>">
            <a href="index.php">
              &nbsp;
            </a>
          </li>
          <?php 
            while ($menu = mysql_fetch_array($menuQuery)) {
              $subMenuQuery = mysql_query("SELECT * FROM rubrique WHERE niveau = " . $menu['id'] . " ORDER BY ordre");  
              $subMenuCount = mysql_num_rows($subMenuQuery);
          ?>
          <li <?php if ($indexMenuSelected == $indexMenu) { echo "class='active'";} ?>
              class="<?php echo $menuCount == $indexMenu ? 'lastMenu' : '';?>">
            <a class='<?php echo $pageSelected['id'] == $menu['id'] ? 'selectedMenu' : ''; ?>'
              <?php if ($subMenuCount == 0) { ?>
                href="index.php?page=<?php echo urlencode($menu['titre']);?>"
              <?php } ?>
              >
              <?php echo stripslashes((($menu['titre']))) ; ?>
            </a>
            <?php
              if ($subMenuCount > 0) {
            ?>
            <ul>
            <?php
              while ($subMenu = mysql_fetch_array($subMenuQuery)) {       
            ?>
              <li>
                <a href="index.php?page=<?php echo urlencode($subMenu['titre']);?>">
                  <?php echo stripslashes((($subMenu['titre'])));?>
                </a>
              </li>
            <?php
            }
            ?>
            </ul> <!-- /Sub menu -->
            <?php } ?>
          </li>
          <?php $indexMenu++; } ?>
        </ul>
      </div><!--/.nav-collapse -->
    </div>
  </div>
</div>
  
  



<?php if (is_file('admin/'.$page.'.php')) { //Menu Administration?>
  
  <?php if ($_SESSION['admin']>0) {?>
  
    <?php
      $menuAdmin = Array();
      array_push($menuAdmin, Array("admin", "ACCUEIL"));
      array_push($menuAdmin, Array("gestionrubrique", "LES RUBRIQUES"));
      array_push($menuAdmin, Array("gestioncategorie", "CATEGORIES"));
      array_push($menuAdmin, Array("gestionimagepatrimoine", "LES PHOTOS"));
      array_push($menuAdmin, Array("gestionequipe", "L'EQUIPE"));
      array_push($menuAdmin, Array("gestioncouleur", "LES COULEURS"));
      array_push($menuAdmin, Array("gestionnews", "LES ACTUALITES"));
      array_push($menuAdmin, Array("gestionuser", "ADMINISTRATEURS"));
      array_push($menuAdmin, Array("managePlayer", "JOUEURS"));
      array_push($menuAdmin, Array("homeContent&amp;action=logout", "DECONNECTION"));
  
      for ($i = 0; $i < count($menuAdmin); $i++) {
    ?>
    <?php $selected = ($page == $menuAdmin[$i][0]); ?>
    <div class="adminMenuElementWrapper" >
      <table>
      	<tr>
        	<td class="title" >
          	<a href="index.php?page=<?php echo $menuAdmin[$i][0]?>"
          	    class="<?php if ($selected){echo 'selected';}?>"
          	    onmouseover="$('#fleche_grise_<?php echo $menuAdmin[$i][0]?>').show();$('#fleche_color_<?php echo $menuAdmin[$i][0]?>').hide();"
          	    onmouseout="$('fleche_grise_<?php echo $menuAdmin[$i][0]?>').hide();$('fleche_color_<?php echo $menuAdmin[$i][0]?>').show()">
          	  <?php echo $menuAdmin[$i][1]?>
          	</a>			
        	</td>
        	<td>
          	<div id="fleche_color_<?php echo $menuAdmin[$i][0]?>" style="display:block;">
          		<img src="images/menu/fleche_<?php echo ($page == $menuAdmin[$i][0]) ? 'verte': 'blanche'; ?>.gif"
          		    class="menuArrow">
          	</div>
          	<div id="fleche_grise_<?php echo $menuAdmin[$i][0]?>" style="display:none;">
          		<img src="images/menu/fleche_grise.gif" class="menuArrow">
          	</div>
        	</td>
      	</tr>
      </table>
    </div>
    <?php
      }
    ?>
    <div style="clear:both"></div>
  <br/>
  
  <?php }?>
  
<?php }?>
</div>